﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Meraz.Core.Data;
using System.Runtime.Serialization;

namespace Meraz.Core.Model
{
    [PetaPoco.TableName("facebooklink")]
    [PetaPoco.PrimaryKey("ID,PostID,TopicID,BoardID", autoIncrement = false)]
    [PetaPoco.ExplicitColumns]
    [Serializable]
    [DataContract]
    public class FacebookTopicPostLink : IEquatable<FacebookTopicPostLink>, IComparable<FacebookTopicPostLink>, IComparable
    {
        public FacebookTopicPostLink() {
            Text = string.Empty;
            Title = string.Empty;
            Url = string.Empty;
            ActualUrl = string.Empty;
            Level1 = string.Empty;
            Level2 = string.Empty;
            Source = string.Empty;
            Tone = string.Empty;
            Status = string.Empty;
            Old = string.Empty;
        }
        [DataMember]
        [PetaPoco.Column]
        public int ID { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public int PostID { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public int TopicID { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public long BoardID { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public int Index { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string Text { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string Title { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string Url { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string ActualUrl { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string Level1 { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string Level2 { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string Broadcast { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string Citation { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string Source { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string Tone { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string Old { get; set; }

        [DataMember]
        [PetaPoco.Column]
        public string Status { get; set; }

        public override bool Equals(object obj)
        {
            if (obj == null)
                return base.Equals(obj);
            FacebookTopicPostLink link = (FacebookTopicPostLink)obj;
            return Equals(link);
        }

        public override int GetHashCode()
        {
            return BoardID.GetHashCode() ^ TopicID.GetHashCode() ^ PostID.GetHashCode() ^ ID.GetHashCode();
        }

        public bool Equals(FacebookTopicPostLink other)
        {
            if (other == null)
                return base.Equals(other);
            if (!BoardID.Equals(other.BoardID)) return false;
            if (!TopicID.Equals(other.TopicID)) return false;
            if (!PostID.Equals(other.PostID)) return false;
            return ID.Equals(other.ID);
        }

        public int CompareTo(FacebookTopicPostLink other)
        {
            if (other == null)
                return 1;
            if (!BoardID.Equals(other.BoardID)) return BoardID.CompareTo(other.BoardID);
            if (!TopicID.Equals(other.TopicID)) return BoardID.CompareTo(other.TopicID);
            if (!PostID.Equals(other.PostID)) return BoardID.CompareTo(other.PostID);
            return ID.CompareTo(other.ID);
        }

        public int CompareTo(object obj)
        {
            if (obj == null)
                return 1;
            FacebookTopicPostLink link = (FacebookTopicPostLink)obj;
            return CompareTo(link);
        }

    }
}
